<?php
error_reporting(E_WARNING);
include_once 'action.php';
include_once '../includes/metodos.php';
connectSql();

if(!empty($_POST['cmd']) && $_POST['cmd']=='faltou'){
	$query = mysql_query("UPDATE tb_agenda SET status=2 WHERE id=".$_POST['id']);
	if($query){
		echo '<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">location.href="index.php";</SCRIPT>';
	}
}

if(!empty($_POST['cmd']) && $_POST['cmd']=='desmarcar'){
	$query = mysql_query("UPDATE tb_agenda SET status=3 WHERE id=".$_POST['id']);
	if($query){
		echo '<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">location.href="index.php";</SCRIPT>';
	}
}

if(!empty($_POST['cmd']) && $_POST['cmd']=='fim'){
	$query = mysql_query("UPDATE tb_agenda SET status=4 WHERE id=".$_POST['id']);
	if($query){
		echo '<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">location.href="../caixa.php?id='.$_POST['id'].'";</SCRIPT>';
	}
}

if(!empty($_POST['cmd']) && $_POST['cmd']=='edit'){
	edit($_POST['id']);	
}

$query= mysql_query("SELECT * FROM tb_agenda WHERE id=".$_POST['id']);
$row = mysql_fetch_array($query);
?>

<form method="post" action="edit.php">
	<label>Cliente:</label>
	<input type="text" name="cliente" value="<?php echo $row['nm_cliente'];?>" disabled="true"><br/>
	<label>Telefone:</label>
	<input type="text" name="tel" value="<?php echo $row['telefone'];?>"/><br/>
	<label>Celular:</label>
	<input type="text" name="cel" value="<?php echo $row['celular'];?>"/><br/>
	<input type="hidden" name="cmd" value="edit"/>
	<input type="hidden" name="id" value="<?php echo $row['id'];?>"/>
	<input type="submit" value="Editar"/>
</form>